package com.lightsaber.trade.as.dao.planning;

import java.util.HashMap;
import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Component;
import org.springside.modules.orm.Page;

import com.lightsaber.trade.as.entity.planning.Level3Planning;
import com.lightsaber.trade.core.dao.BaseDao;

@Component
public class Level3PlanningDao extends BaseDao<Level3Planning, String> {

    @SuppressWarnings("unchecked")
    public List<Integer> getAllPlanningExercise() {

        String hql = "select distinct level3.planningExercise from Level3Planning level3 ";

        Query q = this.createQuery(hql, new HashMap<String, Object>());

        return q.list();
    }

    public Page<Level3Planning> findPage(final Level3Planning level3Planning,
            final Page<Level3Planning> page) {

        int exercise = level3Planning.getPlanningExercise();
        if (exercise != 0) {
            eq("planningExercise", exercise);
        }

        return findPage(page);
    }

}
